# !/usr/bin/python
# -*- coding=utf-8 -*-

from platform import platform


class MSet(object):
    """
    通用配置
    """
    # 容器标记
    DOCKER_FLAG = True

    # S3配置
    S3_FLAG = False

    # 实时调用
    S3_AUTO = False

    # 三方APP
    THIRD_APPS = ()

    # 达梦数据库配置
    DM_DB_FLAG = False
    SYSTEM_VERSION = 'CENTOS7'

    # 错误弹窗配置
    V_POPUP_ERROR = False

    if 'centos' in platform() or 'Linux' in platform():
        DEBUG = False
    else:
        DEBUG = True

    if DEBUG:
        HOST = '127.0.0.1'
        DB_NAME = 'book_management'
        DB_PORT = '3306'
        DB_USER = 'root'
        DB_PWD = '123456'
    else:
        #  用户处正式运行的堡垒机环境
        HOST = '127.0.0.1'
        DB_NAME = 'book_management'
        DB_PORT = '33006'
        DB_USER = 'mysql'
        DB_PWD = '123456'

    # redis 配置
    CACHES = {
        "default": {
            "BACKEND": "django_redis.cache.RedisCache",
            "LOCATION": 'redis://127.0.0.1:6379/1',
            "TIMEOUT": 60 * 5,  # 缓存超时时间（默认30分钟，None表示永不过期，0表示立即过期）
            "OPTIONS": {
                "PICKLE_VERSION": -1,  # 用最新版本的 pickle 实现序列化
                "IGNORE_EXCEPTIONS": True,  # 忽略关闭时触发异常
                "CONNECTION_POOL_KWARGS": {"max_connections": 100},  # 连接池
                "CLIENT_CLASS": "django_redis.client.DefaultClient",
                "PASSWORD": '123123',
                "SOCKET_TIMEOUT": 10,  # 秒 连接建立后  读写超时
                "SOCKET_CONNECT_TIMEOUT": 10,  # 秒  建立连接超时
                # "SERIALIZER": "django_redis.serializers.json.JSONSerializer",
            },
            "KEY_PREFIX": "bookmgt_"
        }
    }
